from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import relationship

from .base import BaseModel
# from werkzeug.security import check_password_hash, generate_password_hash
# @RISK 后面再考虑加密


class User(BaseModel):

    id = Column(Integer, primary_key=True, autoincrement=True)

    nickname = Column(String(20), default='新用户')

    account = Column(String(20), nullable=False)

    password = Column(String(128), nullable=False)

    email = Column(String(50), nullable=True)

    scope = Column(Integer, nullable=False, default=8,
                   comment='用户权限: 8: 普通用户 | 16 | 32 | 666: 超级管理员')

    videos = relationship('Video', backref='user', lazy=True)

    chapters = relationship('Chapter', backref='user', lazy=True)

    courses = relationship('Course', backref='user', lazy=True)

    step = Column(Integer, default=0, nullable=True,
                  comment="遍历的帧间隔， 0: 代表取值为视频的FPS（帧率）")

    speed_x = Column(Integer, default=1, nullable=True,
                     comment="使得真正的step为step*speed_x")
